package com.zzptc.easyshop.util;

import com.zzptc.easyshop.vo.ShopCarGood;

import java.util.ArrayList;
import java.util.List;

public class ShopCarUtil {
    //添加商品
    public static void addGood(ShopCarGood shopCarGood, List<ShopCarGood> list) {
        if (list.size() == 0) {
            list.add( shopCarGood );
            //=0就添加
        } else {
            boolean b = true;
            for (int i = 0; i < list.size(); i++) {
                ShopCarGood s = list.get( i );
                if (shopCarGood.getId() == s.getId()) {
                    //数量加1
                    s.setNum( s.getNum() + 1 );
                    b = false;
                    break;
                }
            }
            if (b) {
                list.add( shopCarGood );
            }
        }
    }
}
    //修改商品数量
    //delete商品

